// pages/detail/detail.js
const app = getApp();

Page({
  data: {
    project: null,
    isLiked: false,
    likeCount: 0,
    comments: [
      {
        id: 1,
        avatar: 'https://example.com/avatar1.jpg',
        name: '张设计师',
        time: '2小时前',
        content: '这个项目的空间布局很有创意，光影效果处理得特别棒！'
      },
      {
        id: 2,
        avatar: 'https://example.com/avatar2.jpg',
        name: '李客户',
        time: '1天前',
        content: '我们公司的展馆就是他们设计的，效果远超预期，强烈推荐！'
      },
      {
        id: 3,
        avatar: 'https://example.com/avatar3.jpg',
        name: '王观察员',
        time: '3天前',
        content: '科技与艺术的完美结合，这种沉浸式体验代表了未来展览的方向。'
      }
    ]
  },

  onLoad(options) {
    const id = parseInt(options.id);
    const project = app.globalData.cases.find(item => item.id === id);
    
    if (project) {
      this.setData({
        project: project,
        likeCount: Math.floor(Math.random() * 100) + 50 // 随机点赞数
      });
    }
  },

  toggleLike() {
    this.setData({
      isLiked: !this.data.isLiked,
      likeCount: this.data.isLiked ? this.data.likeCount - 1 : this.data.likeCount + 1
    });
  }
});